﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Freya.AssemblyLine_F
{

    /// <summary>
    /// 要写入日志的单元对象
    /// </summary>
    public class LogWriteObject : Unit
    {
        public override object Execute(object value)
        {
            if (!Config.Debug.DebugMode)
            {
                return null;
            }
            try
            {
                string[] cache = ((string)value).Split('\n');
                foreach (string i in cache)
                {
                    lock ("WriteLog")
                    {
                        StreamWriter sw = new StreamWriter(File.Open("log.log", FileMode.Append));
                        sw.WriteLine(i);
                        sw.Close();
                    }
                }
            }
            catch (Exception)
            {

            }
            return null;
        }
    }
}
